import React, { useEffect } from 'react';
import './App.scss';
import RouterView from './config/routers-path';
import { useNavigate } from 'react-router-dom';
import { apiPermissionAll } from './services/permissionManager';
import { getUserName } from './utils/commonUtil';


function App() {

  const navigate = useNavigate();
  const getInitialState = async () => {
    const data = await apiPermissionAll({
      userEmail: 'wang.yj.6@pg.com',
      // 'wu.yh.9@pg.com',
      // getUserName(),
    });
    const userPermission = data?.data?.data || {};
    userPermission.userGroup = [
      {
        "userCampRole": "Big Simulation File-Admin",
        "buRole": [
          {
            "bu": "Baby",
            "module": "Big Simulation File",
            "role": [
              "Tester"
            ]
          },
        ]
      },
      {
        "userCampRole": "Experimental Data-Admin",
        "buRole": [
          {
            "bu": "Baby",
            "module": "Experimental Data",
            "role": [
              "Tester"
            ]
          },
        ]
      },
      {
        "userCampRole": "SynTouch-Admin",
        "buRole": [
          {
            "bu": "Baby",
            "module": "SynTouch",
            "role": [
              "Tester"
            ]
          },
        ]
      },
      {
        "userCampRole": "SEM-Admin",
        "buRole": [
          {
            "bu": "Baby",
            "module": "SEM",
            "role": [
              "Tester"
            ]
          },
        ]
      },
      {
        "userCampRole": "IR-Admin",
        "buRole": [
          {
            "bu": "Baby",
            "module": "IR",
            "role": [
              "Tester"
            ]
          },
        ]
      }
    ];
    localStorage.setItem('userAccess', JSON.stringify(userPermission));
  };
  useEffect(() => {
    getInitialState();
  }, [])
  return (
    <RouterView></RouterView>
  );
}

export default App;
